#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019/3/19 17:44
# @Author  : mazhi
# @Site    :
import json

from django.shortcuts import render

# Create your views here.
from django.http import HttpResponse, JsonResponse
import suds

from api.response_models import create_data
from util.jsonresult import getTestResult, getResult


def suds_run():
    from suds.client import Client
    url = "http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx?wsdl"
    url = "http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl"
    client = Client(url)
    print(client)
    # res = client.service.getCountryCityByIp("110.23.25.23")
    # print(res)


def query(request):
    print(request.body)
    print(request.POST)
    b =  json.loads(request.body.decode())
    GUID = b.get("GUID")
    GUID = b.get("GUID")
    CdName = b.get("CdName")
    Sex = b.get("Sex")
    Nation = b.get("Nation")
    Birthdate = b.get("Birthdate")
    Address = b.get("Address")
    IDCode = b.get("IDCode")
    Agency = b.get("Agency")
    Valid = b.get("Valid")
    NewAddress = b.get("NewAddress")
    FPDataLen = b.get("FPDataLen")
    Photo = b.get("Photo")
    CameraPhoto = b.get("CameraPhoto")
    VerifyType = b.get("VerifyType")
    AuthenticationType = b.get("AuthenticationType")
    Authentication = b.get("Authentication")
    Score = b.get("Score")
    data = create_data()
    return getResult(True, "", result=data)


def test(request):
    result = {"status": "错误", "data": "", "city": "北京"}
    return JsonResponse(result)


def index(request):
    result = {"status": "错误", "data": "", "city": "北京"}
    raise Exception();

    return JsonResponse(result)
